package com.dm.exceptions;
import com.dm.utils.ResponseApi;
import com.dm.utils.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @Author DongJunJun
 * @Date 2022/9/6 20:50
 */
@ControllerAdvice
public class ExceptionHandle {

    @ExceptionHandler(BasicException.class)
    @ResponseBody
    public Result handleException(BasicException basicException){
        return ResponseApi.setFail(basicException.getExceptionEnum().code(),basicException.getExceptionEnum().message());
    }

}
